﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SPMS.Log.Core;

namespace SPMS.Log.Utility
{
    /// <summary>
    /// 空白安全上下文提供者
    /// </summary>
    /// <remarks>用于提供空白安全上下文</remarks>
    /// <history>
    /// [zanezeng]               2010/1/13 12:11    创建
    /// </history>
    internal sealed class NullSecurityContextProvider : ISecurityContextProvider
    {
        #region ---ISecurityContextProvider

        /// <summary>
        /// 创建对应给定请求对象的执行安全上下文
        /// </summary>
        /// <param name="consumer">请求安全上下文的请求对象</param>
        /// <returns>创建的对应给定请求对象的执行安全上下文</returns>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2010/1/13 11:56    创建
        /// </history>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2010/1/13 12:12    创建
        /// </history>
        public ISecurityContext CreateSecurityContext( object consumer )
        {
            //返回默认的安全上下文实例
            return DEFAULT_CONTEXT;
        }

        #endregion

        #region ---Property

        /// <summary>
        /// 获得默认的空白安全上下文提供者实例
        /// </summary>
        /// <value>默认的空白安全上下文提供者实例</value>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2010/1/13 12:14    创建
        /// </history>
        public static NullSecurityContextProvider Default
        {
            get
            {
                //返回默认的空白安全上下文提供者实例
                return DEFAULT_INSTANCE;
            }
        }

        #endregion

        #region ---Field

        /// <summary>
        /// 默认的空白安全上下文实例
        /// </summary>
        private static readonly NullSecurityContext DEFAULT_CONTEXT = new NullSecurityContext();

        /// <summary>
        /// 默认的提供者实例
        /// </summary>
        private static readonly NullSecurityContextProvider DEFAULT_INSTANCE = new NullSecurityContextProvider();

        #endregion
    }
}
